<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<link type="text/css" rel="stylesheet" href="../zxy/css/emp_info/emp_detail_edit.css">
	<div id="zxy_ei_emp_detail_eidt_tool">
		<a id="zxy_ei_emp_detail_tool_save" class="easyui-linkbutton"></a>
		<a id="zxy_ei_emp_detail_tool_cancel" class="easyui-linkbutton"></a>
	</div>
	<div class="zxy_ede_content">
		<div class="zxy_ede_view_content">
			<table class="zxy_ede_table">
				<tbody>
					<tr>
						<td><span class="zxy_ede_table_title">性别</span></td>
						<td><input id="zxy_ede_sex" class="easyui-combobox" name="zxy_ede_sex">
					    </td>
					</tr>
					<tr>
						<td><span class="zxy_ede_table_title">身份证号</span></td>
						<td><input class="zxy_ebe_table_item easyui-textbox" 
								value="${emp.empDetailInfo.idCard }" id="zxy_ebe_id_card"></td>
					</tr>
					<tr>
						<td><span class="zxy_ede_table_title">生日</span></td>
						<td><input class="zxy_ebe_table_item easyui-datebox" 
								name="zxy_ebe_birthday" id="zxy_ebe_birthday"
								value="${emp.empDetailInfo.birthday }">
						</td>
					</tr>
					<tr>
						<td><span class="zxy_ede_table_title">最高学历</span></td>
						<td><input id="zxy_ede_education" class="easyui-combobox">
					    </td>
					</tr>
					<tr>
						<td><span class="zxy_ede_table_title">入职日期</span></td>
						<td><input class="zxy_ebe_table_item easyui-datebox" 
								name="zxy_ebe_hire_date" id="zxy_ebe_hire_date"
								value="${emp.empDetailInfo.hireDate }">
						</td>
					</tr>
					<tr>
						<td><span class="zxy_ede_table_title">转正日期</span></td>
						<td><input class="zxy_ebe_table_item easyui-datebox" 
								name="zxy_ebe_corrected_date" id="zxy_ebe_corrected_date"
								value="${emp.empDetailInfo.correctedDate }">
						</td>
					</tr>
					<tr>
						<td><span class="zxy_ede_table_title">离职日期</span></td>
						<td><input class="zxy_ebe_table_item easyui-datebox" 
								name="zxy_ebe_resign_date" id="zxy_ebe_resign_date"
								value="${emp.empDetailInfo.resignDate }">
						</td>
					</tr>	
							
				</tbody>
			</table>
		</div>
	</div>
	
	<div class="zxy_ede_content">
		<div class="zxy_ede_view_content">
			<table class="zxy_ede_table">
				<tbody>
					<tr>
						<td><span class="zxy_ede_table_title">政治面貌</span></td>
						<td><input id="zxy_ede_political" class="easyui-combobox">
					    </td>
					</tr>
					<tr>
						<td><span class="zxy_ede_table_title">健康状况</span></td>
						<td><input id="zxy_ede_health" class="easyui-combobox"
					    		data-options="valueField:'healthId',
					    		textField:'health',url:'../setting/findAllHealthByIfDisabled?ifDisabled=0'">
					    </td>
					</tr>
					<tr>
						<td><span class="zxy_ede_table_title">国籍</span></td>
						<td><input class="zxy_ebe_table_item easyui-textbox" 
								value="${emp.empDetailInfo.nationality }" id="zxy_ebe_nationality"></td>
					</tr>
					<tr>
						<td><span class="zxy_ede_table_title">民族</span></td>
						<td><input id="zxy_ede_nation" class="easyui-combobox"
					    		data-options="valueField:'nationId',
					    		textField:'nation',url:'../setting/findAllNationByIfDisabled?ifDisabled=0'">
					    </td>
					</tr>	
					<tr>
						<td><span class="zxy_ede_table_title">婚姻状况</span></td>
						<td><input id="zxy_ede_marital_status" class="easyui-combobox"/>
					    </td>
					</tr>	
				</tbody>
			</table>
		</div>
	</div>
	
	
	
	<div id="zxy_ede_window"></div>
	
	<input type="hidden" id="zxy_ede_emp_id" value="${emp.empId }"/>
	<input type="hidden" id="zxy_ede_emp_detail_info_id" value="${emp.empDetailInfo.id }"/>
	<input type="hidden" id="zxy_ede_emp_sex" value="${emp.empDetailInfo.sexSetting.sexId }"/>
	<input type="hidden" id="zxy_ede_emp_education" value="${emp.empDetailInfo.educationSetting.educationId }"/>
	<input type="hidden" id="zxy_ede_emp_political" value="${emp.empDetailInfo.politicalSetting.politicalId }"/>
	<input type="hidden" id="zxy_ede_emp_health" value="${emp.empDetailInfo.healthSetting.healthId }"/>
	<input type="hidden" id="zxy_ede_emp_nation" value="${emp.empDetailInfo.nationSetting.nationId }"/>
	<input type="hidden" id="zxy_ede_emp_marital" value="${emp.empDetailInfo.maritalStatus }"/>
	<script>
		var empId=$("#zxy_ei_emp_id").val();
		console.log($("#zxy_ede_emp_birthday").val());
		//获取默认值
		$("#zxy_ede_sex").combobox({
    		valueField:'sexId',
    		textField:'sex',
    		url:'../setting/findAllSexByIfDisabled?ifDisabled=0',
    		onLoadSuccess:function(data){
    			$('#zxy_ede_sex').combobox('setValue',$("#zxy_ede_emp_sex").val());
    		}
		
		});
		$("#zxy_ede_education").combobox({
			valueField:'educationId',
			textField:'education',
			url:'../setting/findAllEducationByIfDisabled?ifDisabled=0',
    		onLoadSuccess:function(data){
    			$('#zxy_ede_education').combobox('setValue',$("#zxy_ede_emp_education").val());
    		}
		});
		$("#zxy_ede_political").combobox({
			valueField:'politicalId',
    		textField:'political',
    		url:'../setting/findAllPoliticalByIfDisabled?ifDisabled=0',
    		onLoadSuccess:function(data){
    			$('#zxy_ede_political').combobox('setValue',$("#zxy_ede_emp_political").val());
    		}
		});
		$("#zxy_ede_health").combobox({
			onLoadSuccess:function(data){
    			$('#zxy_ede_health').combobox('setValue',$("#zxy_ede_emp_health").val());
    		}
		});
		$("#zxy_ede_nation").combobox({
			onLoadSuccess:function(data){
    			$('#zxy_ede_nation').combobox('setValue',$("#zxy_ede_emp_nation").val());
    		}
		});
		$("#zxy_ede_marital_status").combobox({
			textField : 'text',
			valueField : 'value',
			data: [{
				text: '未婚',
				value: '未婚'
			},{
				text: '已婚',
				value: '已婚'
			},{
				text: '离异',
				value: '离异'
			}],
			onLoadSuccess : function(){
			    $('#zxy_ede_marital_status').combobox('setValue',$("#zxy_ede_emp_marital").val());
			}
		});
			
		/* $("#zxy_ebe_birthday").datebox("setValue",$("#zxy_ede_emp_birthday").val());
		$("#zxy_ebe_hire_date").datebox("setValue",'1995-12-21'); */
		/* $("#zxy_ebe_birthday").datebox("setValue",$("#zxy_ede_emp_birthday").val());
		$("#zxy_ebe_hire_date").datebox("setValue",$("#zxy_ede_emp_hire_date").val());
		$("#zxy_ebe_corrected_date").datebox("setValue",$("#zxy_ede_emp_corrected_date").val());
		$("#zxy_ebe_resign_date").datebox("setValue",$("#zxy_ede_emp_resign_date").val()); */
		function zxy_ede_save_emp(){
			var emp_detail_info_id=$("#zxy_ede_emp_detail_info_id").val();
			var emp_sex=$("#zxy_ede_sex").val();
			var emp_id_card=$("#zxy_ebe_id_card").val();
			var birthday=$("#zxy_ebe_birthday").val();
			var education=$("#zxy_ede_education").val();
			var hire_date=$("#zxy_ebe_hire_date").val();
			var corrected_date=$("#zxy_ebe_corrected_date").val();
			var resign_date=$("#zxy_ebe_resign_date").val();
			var political=$("#zxy_ede_political").val();
			var health=$("#zxy_ede_health").val();
			var nationality=$("#zxy_ebe_nationality").val();
			var nation=$("#zxy_ede_nation").val();
			var marital_status=$("#zxy_ede_marital_status").val();
			console.log(emp_sex+"-"+emp_id_card+"-"+birthday+"-"+education+"-"+hire_date+"-"+corrected_date
					+"-"+resign_date+"-"+political+"-"+health+"-"+"-"+nation+nationality+"-"+marital_status);
			$.ajax({
				url:"../emp/updateEmpDetailInfo",
				data:{
					empDetailInfoId:emp_detail_info_id,
					empId:empId,
					empSexId:emp_sex,
					birthday:birthday,
					idCard:emp_id_card,
					educationId:education,
					hireDate:hire_date,
					correctedDate:corrected_date,
					resignDate:resign_date,
					politicalId:political,
					healthId:health,
					nationality:nationality,
					nationId:nation,
					maritalStatus:marital_status,
				},
				success:function(data){
					if(data=="1"){
						alert("修改成功");
						$("#zxy_ei_emp_detail").panel("refresh","../emp/empDetail?empId="+empId);
					}
					else{
						alert("修改失败");
					}
				},
				error:function(){
					alert("修改失败");
				}
			}) 
		}
		function zxy_ede_cancel_emp(){
			$("#zxy_ei_emp_detail").panel("refresh","../emp/empDetail?empId="+empId);
		}
		//保存按钮
		$("#zxy_ei_emp_detail_tool_save").linkbutton({
			 iconCls:'icon-save',
			 text:'保存',
			 onClick:function(){
			    zxy_ede_save_emp();
			 }
		});
		//取消按钮
		$("#zxy_ei_emp_detail_tool_cancel").linkbutton({
			 iconCls:'icon-cancel',
			 text:'取消',
			 onClick:function(){
				 zxy_ede_cancel_emp();
			 }
		});
	</script>
</body>
</html>